/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package base.message;

import java.io.Serializable;
import routing.RouteNodeList;

/**
 * Abstraction of the packet sent by nodes as a mean of communication among them (and the broker).
 * @author artem, Arvanitis Ioannis
 */
public class Message implements Serializable {

    private MessageOriginBean transmitterInfo;
    private MessageOriginBean srcInfo;
    private msgTypes messageType;
    private int messageSize;
    private int time2live;
    private Data data;
    private RouteNodeList targetNodes;
   

    /**
     * Enumeration containing the base message types.
     * New message types may be hopefully added later by the node.
     */
    public static enum msgTypes {
//        ANSWER_TO_NODE_NOTIFICATION_REQUEST,
//        REQUEST_FOR_NODE_NOTIFICATION,
//        ANSWER_TO_NODE_NEIGHBOUR_REQUEST,
//        REQUEST_FOR_NODE_NEIGHBOUR,
//        ANSWER_TO_SERVICE_DATA_REQUEST,
//        REQUEST_FOR_SERVICE_DATA,
//        ANSWER_TO_CLUSTER_ID_REQUEST,
//        REQUEST_FOR_CLUSTER_ID,
//        ANSWER_TO_NODE_INFORMATION_REQUEST,
//        REQUEST_FOR_NODE_INFORMATION,
//        ANSWER_TO_INTERNAL_MESSAGE_REQUEST,
//        REQUEST_FOR_INTERNAL_MESSAGE,
//        CONFIRMATION_MESSAGE,
        DUMMY_MESSAGE
    };

    /**
     * Gets the transmitter's info
     * @return the transmitter's info
     */
    public MessageOriginBean getTransmitterInfo() {
        return transmitterInfo;
    }

    /**
     * Sets the transmitter's info
     * @param transmitterId The transmitter's info
     */
    public void setTransmitterInfo(MessageOriginBean transmitterInfo) {
        this.transmitterInfo = transmitterInfo;
    }

    /**
     * Gets the source's info
     * @return the source's info
     */
    public MessageOriginBean getSrcInfo() {
        return srcInfo;
    }

    /**
     * Sets the source's info
     * @param srcId The source's info
     */
    public void setSrcInfo(MessageOriginBean srcInfo) {
        this.srcInfo = srcInfo;
    }

    /**
     * Gets the message type
     * @return the message type
     */
    public msgTypes getMessageType() {
        return messageType;
    }

    /**
     * Sets the message type
     * @param messageType The message type to set
     */
    public void setMessageType(msgTypes messageType) {
        this.messageType = messageType;
    }

    /**
     * Gets the message size
     * @return the message size
     */
    public int getMessageSize() {
        return messageSize;
    }

    /**
     * Sets the message size
     * @param messageSize the message size to set
     */
    public void setMessageSize(int messageSize) {
        this.messageSize = messageSize;
    }

    /**
     * Gets the time to live
     * @return the time to live
     */
    public int getTime2live() {
        return time2live;
    }

    /**
     * Sets the time to live
     * @param time2live The time to live
     */
    public void setTime2live(int time2live) {
        this.time2live = time2live;
    }

     /**
     * Gets the data
     * @return the data
     */
    public Data getData() {
        return data;
    }

    /**
     * Sets the data
     * @param data The data to set
     */
    public void setData(Data data) {
        this.data = data;
    }

    /**
     * Gets the target nodes
     * @return the target nodes
     */
    public RouteNodeList getTargetNodes() {
        return targetNodes;
    }

    /**
     * Sets the target nodes
     * @param targetNodes The target nodes to set
     */
    public void setTargetNodes(RouteNodeList targetNodes) {
        this.targetNodes = targetNodes;
    }

    /**
     * Representation of a message sent by both the nodes and the broker
     */
    public Message() {
    }

    /**
     * Representation of a message sent by both the nodes and the broker
     * @param msgType The type of the message
     * @param msgSize The size of this message
     * @param ttl The time to live
     * @param data The data contained in this message
     * @param targetNodes Routing information about the target and intermediate nodes
     */
    public Message(msgTypes msgType, int msgSize, int ttl, Data data, RouteNodeList targetNodes) {
        setMessageType(msgType);
        setMessageSize(msgSize);
        setTime2live(ttl);
        setData(data);
        setTargetNodes(targetNodes);
    }

    /**
     * Representation of a message sent by both the nodes and the broker
     * @param transmitterInfo Information about the transmitter
     * @param srcInfo Information about the source
     * @param msgType The type of the message
     * @param msgSize The size of this message
     * @param ttl The time to live
     * @param data The data contained in this message
     * @param targetNodes Routing information about the target and intermediate nodes
     */
    public Message(MessageOriginBean transmitterInfo, MessageOriginBean srcInfo, msgTypes msgType, int msgSize, int ttl, Data data, RouteNodeList targetNodes) {
        setTransmitterInfo(transmitterInfo);
        setSrcInfo(srcInfo);
        setMessageType(msgType);
        setMessageSize(msgSize);
        setTime2live(ttl);
        setData(data);
        setTargetNodes(targetNodes);
    }

}
